/*
*	This is the Extend Unit
*	It accept a 16 bit binary code, then extend it to 32 bits
*	The con is the signal to decide it will do signed extending or zero extending
*	00 for zero extension
*	01 for signed extension
*	10 for upper extensioni
*	Done(2011.4.6)
*/

module Ext(
	In,  //input 16bit Signal
	con, //controll Signal
	Out  //output 32 bit Signal
);
	input[15:0] In;
	input[1:0] con;
	output[31:0] Out;
	
	assign Out = (con == 2'b00) ? {16'b0000000000000000,In}:
			   			((con == 2'b01) ?
			   			{In[15],In[15],In[15],In[15],In[15],In[15],In[15],In[15],
			   			In[15],In[15],In[15],In[15],In[15],In[15],In[15],In[15],In}:
			   			{In,16'b0});
	 
endmodule
